<template>
  <div class="container">
    <div class="basicinfo-container">
      <div class="box basic-info">
        <span>我的昵称</span>
        <div class="info-input">
          <input type="text" ref="nameInput" :value="nameValue">
        </div>
      </div>
      <!-- <div class="box safe-info">
            <span>我的性别</span>
            <div class="info-input">
              <el-select v-model="value" placeholder="请选择">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </div>
          </div> -->
      <div class="box address">
        <span>我的个性签名</span>
        <div class="info-input">
          <textarea name="" id="" cols="30" rows="3" ref="introduceInput" :value="introduce"></textarea>
        </div>
      </div>
      <div class="sumbit-button  ">
        <button class="hover:bg-blue-600" @click="sumbit">保存</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      infoMeunList: [
        '基本资料', "安全资料", "地址管理"
      ],
      options: [{
        value: '选项1',
        label: '男'
      }, {
        value: '选项2',
        label: '女'
      }],
      nameValue: '',
      introduce: '',
      basicInfoList: [
        '我的昵称', '我的性别', '我的个性签名'
      ],
    }
  },
  methods: {
    getUserInfo() {
      this.$taxios
        .postInfo("/getUserInfo", { token: sessionStorage.getItem("token") })
        .then((res) => {
          this.nameValue = res.userInfo.name;
          this.introduce = res.userInfo.introduce
          console.log(this.Address);
        });
    },
    sumbit() {
      console.log("修改用户信息");
      let name = this.$refs.nameInput.value;
      let introduce = this.$refs.introduceInput.values;
      console.log(name)
      console.log(this.introduce)
      this.$taxios.postInfo("/updateUserInfo",{name:name,introduce:introduce}).then((res) => {
        console.log(res);
        location.reload();
        this.$message.promptBox("修改成功","success")
      });
    },
  },
  created(){
    if (sessionStorage.getItem("token")) {
      this.getUserInfo();
    }
  }

}

</script>
<style  lang="less" scoped>
.basicinfo-container {

  // display: none;
  .box {
    width: 100%;
    padding-left: 20px;
    padding-top: 20px;
    padding-right: 20px;
    // background: pink;
    text-align: left;
    box-sizing: border-box;

    span {
      color: rgba(128, 128, 128, 0.8);
    }

    .info-input {
      padding-top: 10px;
      width: 100%;

      input {
        width: 100%;
        outline: none;
        height: 30px;
        padding-left: 10px;
        border: 1px solid rgba(128, 128, 128, 0.5);
        border-radius: 5px;
      }

      input:focus {
        border: 1px solid #2469e5;
      }

      textarea {
        width: 100%;
        outline: none;
        height: 50px;
        padding-top: 10px;
        padding-left: 10px;
        border: 1px solid rgba(128, 128, 128, 0.5);
        border-radius: 5px;
        font-size: 18px;
        resize: vertical;
      }

      textarea:focus {
        border: 1px solid #2469e5;
      }
    }

  }

  .sumbit-button {
    height: 70px;
    text-align: right;
    padding-right: 20px;
    box-sizing: border-box;

    button {
      position: relative;
      top: 10px;
      width: 100px;
      height: 40px;
      border: none;
      border-radius: 5px;
      background: #2469e560;
      color: #fff;
      cursor: pointer;
      transition: .5s;

    }

    button:hover {
      background: #2469e5;
    }
  }
}
</style>